<?php
/**
 * Created by PhpStorm.
 * User: 郭田
 * Date: 17/2/5
 * Time: 下午2:30
 */
namespace App\Models\hvish;
use App\Models\BaseModel;
use Illuminate\Support\Facades\DB;

class UserModel extends BaseModel{
    protected $connection = 'daiyu';
    protected $table='dy_user';
    protected $primaryKey='uid';
    public $timestamps = false;

    public function selectData(){
        //$results=DB::select('select * from dy_user where uid<10 order by uid desc');
        //$results=DB::table('dy_user')
        $results=DB::table('dy_ip')->get();
        //DB::connection('daiyu')->select('select * from dy_ip');//DB::table('dy_ip')->get();
//            DB::table('daiyu.dy_room_master')
//            ->join('dy_user_info','dy_user.uid','=','dy_user_info.uid')->select('daiyu.dy_user.username','daiyu.dy_user.uid','dy_user_info.*')->where('dy_user.uid','=','6')->get();
        return $results;
    }
    public function shiwu($data){
//        $results=DB::table('dy_user_info')->where('uid',1)->update(['phone'=>'1520161612']);//$this->updateBy(['mobile'=>'1520161601'],['uid'=>1]);
//        var_dump($results);

        //var_dump($data);exit;
        DB::beginTransaction();
        try{
//            echo '12';
            var_dump($data);
            $uid=$this->saveBy($data);
            if($uid<1){
                return 1;
            }
            echo $uid;
            $up=$results=DB::table('dy_user_info')->where('uid',1)->update(['phone'=>'1520161662']);//$this->updateBy(['mobile'=>'15201616023'],['uid'=>1]);
            var_dump($up);
            if($up){
                DB::commit();
                return true;
            }
        }catch (\Exception $e){
            DB::rollBack();
            return 2;
        }
        return 3;
    }

}